package com.qm.controller;

import com.qm.pojo.ItemCat;
import com.qm.service.ItemCatService;
import com.qm.vo.LayUITree;
import com.qm.vo.QmResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 @author james
 @create 2021-03-11 20:23
 */
@RestController
@RequestMapping("/item/cat")
public class ItemCatController {

    @Autowired
    private ItemCatService itemCatService;

    @RequestMapping("/findItemCatById")
    public QmResult findItemCatById(Long id) {
        return new QmResult().success(itemCatService.findItemCatById(id));
    }

    /**
     * 查询商品分类树形结构空间
     * 1.url地址：/Item/Cat/list
     * 2.参数：暂时没有
     * 3.返回值结果：List<LayUITree>
     * 4.实现数据传递：id:XXX
     */
    @RequestMapping("/list")
    public List<LayUITree> findItemCatList(){
        return itemCatService.findItemCatList();
        //通过缓存的方式获取数据
//        return itemCatService.findItemCatByCache();
    }

}
